import 'package:Smart/pages/productor007/studytest/flutter_boss/item/joblist_item.dart';
import 'package:Smart/pages/productor007/studytest/flutter_boss/model/job.dart';
import 'package:flutter/material.dart';
// import 'package:flutter_boss/model/job.dart';
// import 'package:flutter_boss/item/joblist_item.dart';

class JobsTab extends StatefulWidget {
   JobsTab({Key key}) : super(key: key);

  @override
  // _JobsTabState createState() => _JobsTabState();
  JobList createState() => new JobList();
}

// class _JobsTabState extends State<JobsTab> {
//   @override
//   Widget build(BuildContext context) {
//     return Container(
//        child: child,
//     );
//   }
// }

class JobList extends State<JobsTab> {
  List<Job> _jobs = [];
  @override
  void initState() {
    super.initState();
    getJobList();
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      backgroundColor: Color.fromARGB(255, 242, 242, 245),
      appBar: AppBar(
        elevation: 0.0,
        title: Text(
          'JAVA',
          style: TextStyle(fontSize: 20.0, color: Colors.white),
        ),
      ),
      body: new ListView.builder(
        itemCount:_jobs.length, 
        itemBuilder: buildJobItem
        // itemBuilder: _buildListItem
      ),
    );
  }
  
  // Widget buildJobItem(BuildContext context, int index) {
  //   // Map newsItem = newsList.news[index];
  //   return Text('jjjjHHHH');
  // }

  Widget buildJobItem(BuildContext context, int index) {
    Job job = _jobs[index];
    var jobItem = new InkWell(
      onTap: () {
        showDialog(
            context: context,
            child: AlertDialog(
              content: Text(
                "尽情期待",
                style: TextStyle(fontSize: 20.0),
              ),
            ));
      },
      child: new JobListItem(job)
    );
    return jobItem;
  }

  void getJobList() {
    setState(() {
      _jobs = Job.fromJson("""
        {
          "list":[
            {
              "name":"前端开发工程师",
              "cname":"航易大数据研究院",
              "size":"C轮",
              "salary":"25k-45k",
              "username":"谭鹏",
              "title":"HR",
              "address":"江北区 观音桥"
            },
            {
              "name":"HTML5前端工程师",
              "cname":"重庆鹏领房滴",
              "size":"C轮",
              "salary":"40k-45k",
              "username":"张先生",
              "title":"技术总监",
              "address":"渝北区 财富中心"
            }
          ]
        }
      """);
    });
  }
}
